package test.zuche;

import java.util.Scanner;

public class TextCar {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Business wu = new Business();
        wu.infor();
        while (true) {
            System.out.println("1.查看车辆 2.租车 3.还车 4.报废车辆 5.买新车 6.租车记录查询 ");
            System.out.println("请输入选择");
            int n = in.nextInt();
            switch (n) {
                case 1:
                    wu.inforche();
                    break;
                case 2:
                    System.out.println("请输入车牌");
                    String chepai = in.next();
                    if (wu.panduan(chepai) != null) {
                        System.out.println("请输入开始时间");
                        String kaiday=in.next();
                        System.out.println("请输入结束时间");
                        String jieday = in.next();
                        System.out.println("请输入租的天数");
                        int day = in.nextInt();
                        double money=wu.zu(day, chepai);
                        wu.setJilu(day,chepai,kaiday,jieday,money);
                        System.out.println("需要支付的钱为：" + wu.zu(day, chepai));
                    } else System.out.println("查无此车");
                    break;
                case 3:
                    System.out.println("请输入要还车的车牌");
                    String chepai1 = in.next();
                    wu.huan(chepai1);
                    break;
                case 4:
                    System.out.println("请输入要报废车的车牌");
                    String chepai2 = in.next();
                    wu.scrapped(chepai2);
                    break;
                case 5:
                    System.out.println("请输入新车类型 1.轿车 2.客车");
                    int a;
                    while (true){
                        a = in.nextInt();
                        if (a==1||a==2){
                            break;
                        }
                        System.out.println("输入非法数字,重来");
                    }
                    System.out.println("请输入车牌");
                    String pai=in.next();
                    if (wu.panpai(pai)==null){
                        if (a == 1) {
                            MinCar newcar = new MinCar();
                            System.out.println("请输入车名");
                            newcar.setName(in.next());
                            newcar.setChepai(pai);
                            System.out.println("请输入车日租金");
                            newcar.setMoney(in.nextInt());
                            wu.add(newcar);
                        } else if (a == 2) {
                            KeCar newcar = new KeCar();
                            System.out.println("请输入车名");
                            newcar.setName(in.next());
                            newcar.setChepai(pai);
                            System.out.println("请输入车日租金");
                            newcar.setMoney(in.nextInt());
                            System.out.println("请输入座位数");
                            newcar.setNum(in.nextInt());
                            wu.add(newcar);
                        }}
                    break;
                case 6:wu.zuchejilu();
                    break;
//                default:
//                    return;

            }
        }
    }
    }

